package pers.muci.job;

import org.quartz.*;

public class ParamJob implements Job {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        JobKey jobKey = jobExecutionContext.getJobDetail().getKey();
        System.out.println("工作名称：" + jobKey.getName() + "；工作任务组：" + jobKey.getGroup());
        System.out.println("任务类名称（带包名）：" + jobExecutionContext.getJobDetail().getJobClass().getName());
        System.out.println("任务类名称：" + jobExecutionContext.getJobDetail().getJobClass().getSimpleName());
        System.out.println("当前任务执行时间：" + jobExecutionContext.getFireTime());
        System.out.println("下一任务执行时间：" + jobExecutionContext.getNextFireTime());

        TriggerKey triggerKey = jobExecutionContext.getTrigger().getKey();
        System.out.println("触发器名称：" + triggerKey.getName() + ";触发器组：" + triggerKey.getGroup());

        JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
        String jobMessage = jobDataMap.getString("message");
        System.out.println("任务参数消息值：" + jobMessage);

        JobDataMap triggerDataMap = jobExecutionContext.getTrigger().getJobDataMap();
        String triggerMessage = triggerDataMap.getString("message");
        System.out.println("触发器参数消息值：" + triggerMessage);

    }


    /**
     * 若 Job 类中存在JobDataMap中对应的键属性，那么会默认将其赋值，且 Trigger 中的优先级会更高
     */
    private String msg;

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
